package xfuzzy.alg_genetico.indeterminado.codification;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class ForwardToBackwardConfiguration {

	public static void main(String [] args)  {
		
		String path_in = "configurations_6_forward_v01.txt";
		String path_out = "configurations_6_backward_v01.txt";
		String input_data = "";
		String configuration_in = "";
		String configuration_out = "";
		char [] config_forward = null;
		char [] config_backward = null;
		BufferedReader in = null;
		BufferedWriter out = null;
		try  {
			in = new BufferedReader(new FileReader(path_in));
			out = new BufferedWriter(new FileWriter(path_out));
			input_data = in.readLine();
			while (input_data != null)  {
				configuration_in = input_data.split(" : ")[0];
				config_forward = configuration_in.toCharArray();
				config_backward = new char[config_forward.length];
				for (int i = config_forward.length - 1; i >= 0; i--)  {
					 config_backward[config_forward.length - 1 - i] = config_forward[i];
				}
				System.out.println(configuration_in);
				configuration_out = String.valueOf(config_backward);
				System.out.println(configuration_out);
				configuration_out += " : " + input_data.split(" : ")[1];
				out.write(configuration_out + "\n");
				input_data = in.readLine();
			}
			in.close();
			out.close();
		}
		catch(Exception e)  {
			System.out.println(e.getMessage());
			e.printStackTrace();
		}
	}
}
